<?php

/**
 * Object used to manage customers and their information
 * 
 * @package Customer
 * @author Guillem Mateos
 * @version 0.1
 * @abstract 
 * @copyright GRITO2003, S.L.
 */

/**
 * includes
 */
//include_once( '../library/config.php' );
include_once( FROG_DATABASE.'DBObject.class.php' );

class Paymentrequest extends DBObject
{
  /**
  * Initialize vars
  */
  public function initVars( )
  {
    $this->dbfields['id_paymentrequest'] = null;
    $this->dbfields['id_payment'] = null;
    $this->dbfields['amount'] = null;
    $this->dbfields['email'] = null;
    $this->dbfields['paid'] = null;
    
    $this->dbparams['table'][0] = 'paymentrequest';
    $this->dbparams['main_id'] = 'id_paymentrequest';
  }
  
  public static function findByEmail( $e )
  {   
    if( !$e )
      return false;
      
    $c = new Paymentrequest();
        
    $w_expr_01 = new Expression( 'email', '=', $e );

    $result = $c->select( '', $w_expr_01  );
    
    return $result;
  }
  
  public static function findByEmailAndIdPayment( $e, $idp ) {
  	$c = new Paymentrequest();
  	
  	if( isset( $e ) )
      $exprs[] = new Expression( 'email', '=', $e );
    if( isset( $idp ) )
      $exprs[] = new Expression( 'id_payment', '=', $idp );
    $union = new Union( 'AND', $exprs );
    
    $result = $c->select( '', $union );
    
    return $result;
  }
} 

?>